package com.example.demo.manager;

import com.example.demo.navigation.bean.NavBean;
import com.example.demo.navigation.service.NavService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("Admin")
public class managerController {


    @Autowired
    private NavService navService;

    @RequestMapping("index")
    public String index(Model model){
        model.addAttribute("navs",navService.getList(0));
        return "/manager/index";
    }

    @RequestMapping("welcome")
    public String welcome(Model model){
        return "/manager/welcome";
    }

    @RequestMapping("nav")
    @ResponseBody
    public List<NavBean> navTest(){
        return navService.getList(1);
    }

    @RequestMapping("nav/{id}")
    @ResponseBody
    public List<NavBean> navById(@PathVariable int id){
        return navService.getList(1,id);
    }
}
